<?php
/**
 * Created by PhpStorm.
 * User: chain
 * Date: 2020-02-17
 * Time: 15:24
 */

namespace App\Http\Controllers\System;


use App\Common\Utils\JsonResponse;
use App\Http\Controllers\Controller;
use App\Http\Request\System\Log\ListRequest;

class LogController extends Controller
{
    /**
     * @var \App\Services\System\LogService $logService
     */
    private $logService;
    /**
     * Create a new controller instance.
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
        $this->middleware('auth');
        $this->logService = app('logService');
    }
    public function index()
    {
        return view('systems.logs.index');
    }
    /**
     * 获取列表
     */
    public function getList(ListRequest $request)
    {
        try
        {
            if(!$request->isValid()){
                throw new \Exception($request->getErrMsg());
            }else{
                $requestData = $request->getData();
                $result = $this->logService->getList($requestData);
                return JsonResponse::get($result['data'],TRUE,$result['total']);
            }
        }
        catch(\Exception $e)
        {
            return $this->error($e);
        }
    }
}